package com.card.user;

import java.util.Date;
import java.util.List;

import com.card.game.BasePlayer;
import com.card.game.ddz.DdzRoom;
import com.card.game.dn.NnRoom;
import com.card.game.log.ShResult;
import com.card.game.log.ShResults;
import com.card.game.pdk.PdkRoom;
import com.card.game.room.AbstractRoom;
import com.card.game.room.TggRoom;
import com.google.common.collect.Lists;
import com.xiaoao.net.utils.TimeUtils;

public class RoomBack{
	String date;
	int roomId;
	String ownId;//新加 代表 房主id
	int juNum; //新加
	List<UserBack> backs = Lists.newArrayList();
	//新加玩家用户id
	List<String> uids = Lists.newArrayList();
	List<String> names = Lists.newArrayList();
	List<String> urls = Lists.newArrayList();//增加头像
	List<Integer> scores = Lists.newArrayList();
	
	public RoomBack(AbstractRoom room) {
		this.roomId = room.getId();
		this.ownId = room.getOwnerId();
		this.juNum = room.getRoomSetting().getMaxPlayNum();
		this.date = TimeUtils.ToString2(new Date());
	}
	
	public RoomBack(int roomId,String ownId) {
		this.roomId = roomId;
		this.ownId = ownId;
		this.date = TimeUtils.ToString2(new Date());
	}
	public void addBackList(ShResults shResults,UserBack back) {
		this.names.clear();
		this.scores.clear();
		this.uids.clear();
		this.urls.clear();
		for (ShResult result : shResults.getResultList()) {
			this.names.add(result.getNickName());
			this.scores.add(result.getScore());
			this.uids.add(result.getUserId());
			this.urls.add(result.getImg());
		}
		this.backs.add(back);
	}
	public void addBackList(AbstractRoom room,UserBack back) {
		this.names.clear();
		this.scores.clear();
		this.uids.clear();
		this.urls.clear();
		for (BasePlayer player : room.getPlayerList()) {
			this.names.add(player.nickName);
			this.scores.add(player.getScore());
			this.uids.add(player.getUserId());
			this.urls.add(player.img);
		}
		this.backs.add(back);
	}
	
	public void addBackList(UserBack back) {
		this.backs.add(back);
	}
	public void loadScore(TggRoom room) {
		for (BasePlayer player : room.getPlayerList()) {
			this.names.add(player.nickName);
			this.scores.add(player.getScore());
			this.uids.add(player.getUserId());
			this.urls.add(player.img);
		}
	}
	
	public void loadScore(NnRoom room) {
		for (BasePlayer player : room.getPlayerList()) {
			this.names.add(player.nickName);
			this.scores.add(player.getScore());
			this.uids.add(player.getUserId());
			this.urls.add(player.img);
		}
	}
	
	public void loadScore(DdzRoom room) {
		for (BasePlayer player : room.getPlayerList()) {
			this.names.add(player.nickName);
			this.scores.add(player.getScore());
			this.uids.add(player.getUserId());
			this.urls.add(player.img);
		}
	}
	
	public void loadScore(PdkRoom room) {
		for (BasePlayer player : room.getPlayerList()) {
			this.names.add(player.nickName);
			this.scores.add(player.getScore());
			this.uids.add(player.getUserId());
			this.urls.add(player.img);
		}
	}
}
